home *** CD-ROM | disk | FTP | other *** search
Korn shell script | 1996-11-11 | 2.4 KB | 77 lines |
- #!/bin/ksh -p
- # run wrapper around xconfirm so can have more flexible text for window and
- # so check made for failure
-
- export PATH="/usr/bsd:/bin:/usr/bin:/usr/sbin:/usr/bin/X11"
-
- OLD_IFS="$IFS"
- IFS="\n"
- typeset options="$1" mesg="$2" special_header="$3"
- IFS="$OLD_IFS"
- typeset -i ignore_ret=0
- base_button="Continue"
- base_error="-B $base_button -icon error"
- base_warn="-B $base_button -icon warning"
- base_info="-B $base_button -icon info"
- error_opt="$base_error -header \"ToolBox Error\""
- warn_opt="$base_warn -header \"ToolBox Warning\""
- info_opt="$base_info -header \"ToolBox Information\""
-
- if [[ "$options" = "error" ]]; then
- options="$error_opt"
- ((ignore_ret=1))
- elif [[ "$options" = "warn" ]]; then
- options="$warn_opt"
- ((ignore_ret=1))
- elif [[ "$options" = "header" ]]; then
- options="$base_error -header \"$special_header\""
- ((ignore_ret=1))
- elif [[ "$options" = "notviewDT" ]]; then
- options="$error_opt"
- mesg="This command cannot be run in standalone mode\n\
- It is run as part of viewDT from a Developer Toolbox CD\n\n\
- Please read the liner notes from the CD for more details."
- ((ignore_ret=1))
- elif [[ "$options" = "nohome" ]]; then
- options="$error_opt"
- mesg="Could not determine user home directory.\n\
- Please make sure the environment variable HOME\n\
- is set to be your user home directory.\n\
- Then rerun this command."
- ((ignore_ret=1))
- elif [[ "$options" = "yesno" ]]; then
- options="-B Yes -b No -header ToolBox_Question -icon question"
- elif [[ "$options" = "select" ]]; then
- options="-b Help -b Quit -B View -header \"Toolbox as $USER\" -icon question"
- elif [[ "$options" = "select_again" ]]; then
- options="-b Help -B Quit -b View -header \"Toolbox as $USER\" -icon question"
- fi
-
- unset tval
- IFS="\n"
- echo "$mesg" | while read line; do
- tval="$tval -t \""
- while [[ "${line##*\"*}" = "" ]]; do
- [[ "$line" = "" ]] && break
- tval="$tval${line%%\"*}\\\""
- line="${line##*([!\"])\"}"
- done
- tval="$tval$line\""
- done
- tval="xconfirm $options $tval"
- IFS="$OLD_IFS"
- if ((ignore_ret)); then
- eval $tval > /dev/null
- else
- eval $tval
- fi
- if (($?)); then
- echo "\n**********************************************************"
- echo "Error when trying to run xconfirm"
- echo "For some reason X programs will not successfully run."
- echo "Perhaps your DISPLAY environment variable is improperly set."
- echo "\nThe body of the xconfirm message was:\n\n$mesg"
- echo "**********************************************************\n\n"
- exit 1
- fi
-